package com.example.hbutliving.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 测试请求头工具类
 */
@Component
public class HeaderUtil {

  @Autowired
  private JwtUtil jwtUtil;

  /**
   * 获取默认100号用户请求头
   * @return
   */
  public Map<String,String> getDefaultHeader(){
    Map<String,String> defaultHeader = new HashMap<>(4);
    defaultHeader.put("token",jwtUtil.createUserToken(100));
    return defaultHeader;
  }


  /**
   * 获取指定id用户请求头
   * @param userId 用户id
   * @return
   */
  public Map<String,String> getHeaderByUserId(int userId){
    Map<String,String> header=new HashMap<>(4);
    header.put("token",jwtUtil.createUserToken(userId));
    return header;
  }
}
